﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CUREBusinessLogicLayer;
using CUREEntity;
using CURE.Handler;
using System.Data;
using System.Text.RegularExpressions;
using System.Web.SessionState;

/*************************************************************************************

     * 作   者： 张 颖
  
*************************************************************************************/
namespace CURE.SystemManagement
{
    public partial class UserManagement : System.Web.UI.Page
    {
        #region 分页变量，与UI绑定
        private int numPerPage;
        /// <summary>
        /// 每页显示的条数
        /// </summary>
        public int NumPerPage
        {
            get
            {
                int temp = Convert.ToInt32(Request.Form["numPerPage"]);
                return temp == 0 ? 20 : temp;
            }
            set { numPerPage = value; }
        }
        private int pageNumShown = 10;
        /// <summary>
        /// 页数导航的个数
        /// </summary>
        public int PageNumShown
        {
            get { return pageNumShown; }
            set { pageNumShown = value; }
        }
        private int pageNum;
        /// <summary>
        /// 当前显示的页数
        /// </summary>
        public int PageNum
        {
            get
            {
                int temp = Convert.ToInt32(Request.Form["pageNum"]);
                return temp == 0 ? 1 : temp;
            }
            set { pageNum = value; }
        }
        private int totalCount;
        /// <summary>
        /// 总条数
        /// </summary>
        public int TotalCount
        {
            get { return totalCount; }
            set { totalCount = value; }
        }
        #endregion
        #region 变量
        private string id;

        public string Id
        {
            get { return id; }
            set { id = value; }
        }
        private string name;

        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        #endregion
        MasterBll masterBll = new MasterBll();
        protected void Page_Load(object sender, EventArgs e)
        {
            JudgeAuthority ja = new JudgeAuthority();
            if (ja.JudgeUserAuthorityByGroupId("SystemManagement/UserManagement.aspx"))
            {
                id = Request.Form["id"];
                name = Request.Form["name"];
                BindData();
            }
            else
            {
                Response.Write("<script language=javascript>top.location.href='../../Login.aspx';</script>");
                Response.End();
            }
        }
        /// <summary>
        /// 绑定用户数据
        /// </summary>
        protected void BindData()
        {
            IDictionary<string, object> dic = new Dictionary<string, object>();
            dic.Add("id", id);
            dic.Add("name", name);
            int totalPageCount;
            DataSet ds = masterBll.GetMasterData(dic, PageNum, NumPerPage, out totalCount, out totalPageCount);
            if (ds != null)
            {
                reptMaster.DataSource = ds;
                reptMaster.DataBind();
            }
        }

        //protected void reptMaster_ItemDataBound(object sender, RepeaterItemEventArgs e)
        //{
        //    Label aa = (Label)e.Item.FindControl("SKILL_TRANSPORT");
        //    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        //    {
        //        string a = DataBinder.Eval(e.Item.DataItem, "SKILL_TRANSPORT").ToString();
        //        string b = DataBinder.Eval(e.Item.DataItem, "SKILL_PACKAGING").ToString();
        //        string c = DataBinder.Eval(e.Item.DataItem, "SKILL_SHIPMENTS").ToString();
        //        if (!string.IsNullOrEmpty(a))
        //        {
        //            aa.Text = a + "%";
        //        }
        //    }
        //}

    }
}